using System;
using System.Configuration.Provider;

namespace Wax.Provider
{
   /// <summary>
    /// Provids a strongly typed collection of <see cref="WaxDataProviderBase">WaxDataProviderBase</see>
   /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
   public class WaxDataProviderCollection : ProviderCollection
    {
        /// <summary>
        /// Adds a provider to the collection.
        /// </summary>
        /// <param name="provider">The provider to be added.</param>
        /// <exception cref="T:System.ArgumentException">The <see cref="P:System.Configuration.Provider.ProviderBase.Name"></see> of provider is null.- or -The length of the <see cref="P:System.Configuration.Provider.ProviderBase.Name"></see> of provider is less than 1.</exception>
        /// <exception cref="T:System.ArgumentNullException">provider is null.</exception>
        /// <exception cref="T:System.NotSupportedException">The collection is read-only.</exception>
        /// <PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/></PermissionSet>
       [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentNullException.#ctor(System.String,System.String)"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String,System.String)"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String)")]
        public override void Add(ProviderBase provider)
        {
            if (provider == null)
                throw new ArgumentNullException("provider", "The provider parameter cannot be null.");

            if (!(provider is WaxDataProviderBase))
                throw new ArgumentException("The provider parameter must be of type WaxDataProviderBase.", "provider");

            base.Add(provider);
        }

        /// <summary>
        /// Gets the <see cref="WaxDataProviderBase"/> with the specified name.
        /// </summary>
        /// <value></value>
       new public WaxDataProviderBase this[string name]
        {
            get { return (WaxDataProviderBase)base[name]; }
        }

        /// <summary>
        /// Copies to this collection to an array.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <param name="index">The index.</param>
       public void CopyTo(WaxDataProviderBase[] array, int index)
        {
            base.CopyTo(array, index);
        }
    }
}
